home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / text / edit / tecoc-146.lha / exep.c < prev    next >
C/C++ Source or Header  |  1991-07-05  |  2KB  |  73 lines

  1. /*****************************************************************************
  2.  
  3.     ExeP()
  4.  
  5.     This function executes a P or PW command.
  6.     nP    Advance n pages
  7.     m,nP    Write out chars m to n
  8.     nPW    Write buffer n times
  9.     m,nPW    Write out chars m to n
  10.  
  11. *****************************************************************************/
  12.  
  13. #include "zport.h"        /* define portability identifiers */
  14. #include "tecoc.h"        /* define general identifiers */
  15. #include "defext.h"        /* define external global variables */
  16. #include "deferr.h"        /* define identifiers for error messages */
  17.  
  18. DEFAULT ExeP()            /* execute a P or PW command */
  19. {
  20.     BOOLEAN    SavEof;
  21.  
  22.     DBGFEN(1,"ExeP",NULL);
  23.  
  24.  
  25.     SavEof = IsEofI[CurInp];        /* save end-of-file flag */
  26.  
  27.     if (EStTop == EStBot) {            /* if no numeric argument */
  28.         NArgmt = 1;            /* default is 1P */
  29.     } else {
  30.         if (GetNmA() == FAILURE) {    /* get numeric argument */
  31.             DBGFEX(1,DbgFNm,"FAILURE");
  32.             return FAILURE;
  33.         }
  34.         if ((NArgmt <= 0) && ((CmdMod & MARGIS) == 0)) {
  35.             ErrMsg(ERR_IPA);    /* negative or 0 arg to P */
  36.             DBGFEX(1,DbgFNm,"FAILURE");
  37.             return FAILURE;
  38.         }
  39.     }
  40.  
  41. /*
  42.  * If it's a "PW" or "m,nP" command,  let ExePW handle it.
  43.  */
  44.     if ((CBfPtr != CStEnd) &&
  45.         ((*(CBfPtr+1) == 'W') || (*(CBfPtr+1) == 'w'))) {
  46.         ++CBfPtr;            /* skip the "W" */
  47.         DBGFEX(1,DbgFNm,"ExePW");
  48.         return ExePW();            /* execute a PW command */
  49.     }
  50.  
  51.     if (CmdMod & MARGIS) {            /* if it's m,nP */
  52.         DBGFEX(1,DbgFNm,"ExePW");
  53.         return ExePW();            /* execute a PW command */
  54.     }
  55.  
  56.     do {
  57.         if (SinglP() == FAILURE) {
  58.             DBGFEX(1,DbgFNm,"FAILURE");
  59.             return FAILURE;
  60.         }
  61.     } while ((--NArgmt > 0) && !IsEofI[CurInp]);
  62.  
  63.     if (CmdMod & COLON) {            /* if it's :P */
  64.         DBGFEX(1,DbgFNm,SavEof ? "PushEx(0)" : "PushEx(-1)");
  65.         return PushEx(SavEof ? 0L : -1L, OPERAND);
  66.     }
  67.  
  68.     CmdMod = '\0';                /* clear modifiers flags */
  69.  
  70.     DBGFEX(1,DbgFNm,"SUCCESS");
  71.     return SUCCESS;
  72. }
  73.